<template>
	<div class="init-page">
		<section class="menu-list-wrapper">
			<Icon v-for="icon in menuList" :key="icon.icon" :name="icon.icon" />
			<svg width="200" height="200" class="icon">
				<line class="svg-icon" x1="0" y1="50%" x2="100%" y2="50%" />
			</svg>
		</section>
	</div>
</template>

<script setup>
	import { onMounted } from 'vue'
	import Icon from '@/components/svgIcon/index.vue'

	const menuList = [
		{
			icon: 'menu-manage'
		},
		{
			icon: 'data-manage'
		},
		{
			icon: 'user-manage'
		},
		{
			icon: 'tool-manage'
		},
		{
			icon: 'settings-manage'
		}
	]

	onMounted(() => {
		const ps = document.querySelectorAll('.svg-icon')

		ps.forEach((p) => {
			const length = p.getTotalLength()
			p.style.setProperty('--l', length)
		})
	})
</script>

<style lang="scss">
	.menu-list-wrapper {
		display: flex;
		width: 100%;
		padding: 50px;
		box-sizing: border-box;
		// background: #fff;

		.icon {
			width: 50px;
			height: 50px;
			margin: auto;
			cursor: pointer;

			.svg-icon {
				fill: none;
				stroke: #fff;
				stroke-width: 5;
				stroke-dashoffset: var(--l);
				stroke-dasharray: var(--l);
				animation: stroke 2s linear forwards;
			}
		}

		@keyframes stroke {
			to {
				stroke-dashoffset: 0;
			}
		}
	}
</style>
